<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.0.0">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="alternate" href="/atom.xml" title="el's blog" type="application/atom+xml">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '7.5.0',
    exturl: false,
    sidebar: {"position":"right","display":"post","offset":12,"onmobile":false},
    copycode: {"enable":false,"show_result":false,"style":null},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    bookmark: {"enable":false,"color":"#222","save":"auto"},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: 'search.xml',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    },
    sidebarPadding: 40
  };
</script>

  <meta name="description" content="切换显示服务状态、DDL、DML等基本操作">
<meta property="og:type" content="article">
<meta property="og:title" content="mysql 常用命令">
<meta property="og:url" content="http:&#x2F;&#x2F;ever-lose.gitee.io&#x2F;2016&#x2F;12&#x2F;24&#x2F;database&#x2F;mysql-command-in-common-use&#x2F;index.html">
<meta property="og:site_name" content="el&#39;s blog">
<meta property="og:description" content="切换显示服务状态、DDL、DML等基本操作">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2019-11-08T06:19:30.884Z">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://ever-lose.gitee.io/2016/12/24/database/mysql-command-in-common-use/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>mysql 常用命令 | el's blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">el's blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <h1 class="site-subtitle" itemprop="description">everlose's blog</h1>
      
  </div>

  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>

</nav>
  <div class="site-search">
    <div class="popup search-popup">
    <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocorrect="off" autocapitalize="none"
           placeholder="搜索..." spellcheck="false"
           type="text" id="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result"></div>

</div>
<div class="search-pop-overlay"></div>

  </div>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content">
            

  <div class="posts-expand">
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block " lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://ever-lose.gitee.io/2016/12/24/database/mysql-command-in-common-use/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpeg">
      <meta itemprop="name" content="everlose">
      <meta itemprop="description" content="focus on Js、CSS、Node...etc">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="el's blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          mysql 常用命令
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2016-12-24 00:00:00" itemprop="dateCreated datePublished" datetime="2016-12-24T00:00:00+08:00">2016-12-24</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-11-08 14:19:30" itemprop="dateModified" datetime="2019-11-08T14:19:30+08:00">2019-11-08</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/database/" itemprop="url" rel="index">
                    <span itemprop="name">database</span>
                  </a>
                </span>
            </span>

          
            <div class="post-description">切换显示服务状态、DDL、DML等基本操作</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="启动"><a href="#启动" class="headerlink" title="启动"></a>启动</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">service mysql start</span><br></pre></td></tr></table></figure>

<p>lsof -i -n 检查网络</p>
<p>netstat -a -p -n -t </p>
<p>service是一个管理程序的命令， mysql是/etc/ini下的程序，start是指令开启。</p>
<p>例如<code>service nginx restart</code></p>
<p>更改root密码为</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">mysql -u root</span><br><span class="line">SET PASSWORD FOR <span class="string">'root'</span>@<span class="string">'localhost'</span> = PASSWORD(<span class="string">'chentongta'</span>);</span><br></pre></td></tr></table></figure>

<h2 id="登录"><a href="#登录" class="headerlink" title="登录"></a>登录</h2><p>当 MySQL 服务已经运行时, 我们可以通过MySQL自带的客户端工具登录到MySQL数据库中,<br>首先打开命令提示符, 输入以下格式的命名:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mysql -h主机名 -u用户名 -p端口名</span><br></pre></td></tr></table></figure>

<ul>
<li>-h : 该命令用于指定客户端所要登录的MySQL主机名, 登录当前机器该参数可以省略;</li>
<li>-u : 所要登录的用户名;</li>
<li>-p : 告诉服务器将会使用一个密码来登录, 如果所要登录的用户名密码为空, 可以忽略此选项。</li>
</ul>
<p>以登录刚刚安装在本机的MySQL数据库为例，在命令行下输入 mysql -u root -p 按回车确认，如果安装正确且MySQL正在运行，会得到以下响应：</p>
<pre><code>Enter password:</code></pre><p>若密码存在， 输入密码登录，不存在则直接按回车登录， 按照本文中的安装方法， 默认 root 账号是无密码的。<br>登录成功后你将会看到 Welecome to the MySQL monitor… 的提示语。</p>
<p>然后命令提示符会一直以 mysql&gt; 加一个闪烁的光标等待命令的输入， 输入 exit 或 quit 退出登录。</p>
<p>公司：mysql  -u root –socket=/var/lib/mysql/mysql.sock</p>
<h2 id="创建数据库"><a href="#创建数据库" class="headerlink" title="创建数据库"></a>创建数据库</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">create database 数据库名 [其他选项];</span><br></pre></td></tr></table></figure>

<p>例如：<code>create database samp_db character set gbk;</code>。</p>
<p>为了便于在命令提示符下显示中文， 在创建时通过 character set gbk 将数据库字符编码指定为 gbk。创建成功时会得到 Query OK, 1 row affected(0.02 sec) 的响应。</p>
<p><strong>注意</strong>: MySQL语句以分号作为语句的结束, 若在语句结尾不添加分号时,<br>命令提示符会以 -&gt; 提示你继续输入(有个别特例, 但加分号是一定不会错的);</p>
<p><strong>提示</strong>: 可以使用 show databases; 命令查看已经创建了哪些数据库。</p>
<h2 id="选择所要操作的数据库"><a href="#选择所要操作的数据库" class="headerlink" title="选择所要操作的数据库"></a>选择所要操作的数据库</h2><p>要对一个数据库进行操作, 必须先选择该数据库, 否则会提示错误:</p>
<pre><code>ERROR 1046(3D000): No database selected</code></pre><p>两种方式对数据库进行使用的选择:</p>
<ol>
<li>在登录数据库时指定, 命令: mysql -D 所选择的数据库名 -h 主机名 -u 用户名 -p<br>例如登录时选择刚刚创建的数据库: mysql -D samp_db -u root -p</li>
<li>在登录后使用 use 语句指定, 命令: use 数据库名;<br>use 语句可以不加分号, 执行 use samp_db 来选择刚刚创建的数据库,<br>选择成功后会提示: Database changed</li>
</ol>
<h2 id="建表"><a href="#建表" class="headerlink" title="建表"></a>建表</h2><p>使用 create table 语句可完成对表的创建, create table 的常见形式:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">create table 表名称(列声明);</span><br></pre></td></tr></table></figure>

<p>以创建 students 表为例, 表中将存放 学号(id)、姓名(name)、性别(sex)、年龄(age)、联系电话(tel) 。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">create table students</span><br><span class="line">(</span><br><span class="line">id int unsigned not null auto_increment primary key,</span><br><span class="line">name char(8) not null,</span><br><span class="line">sex char(4) not null,</span><br><span class="line">age tinyint unsigned not null,</span><br><span class="line">tel char(13) null default &quot;-&quot;</span><br><span class="line">);</span><br></pre></td></tr></table></figure>

<p>数据类型参照<a href="http://www.cnblogs.com/zbseoag/archive/2013/03/19/2970004.html" target="_blank" rel="noopener">这篇文章</a> </p>
<p><strong>提示</strong>: 1. 使用 show tables; 命令可查看已创建了表的名称; 2. 使用 describe 表名; 命令可查看已创建的表的详细信息。</p>
<h2 id="插入数据insert"><a href="#插入数据insert" class="headerlink" title="插入数据insert"></a>插入数据insert</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">insert [into] 表名 [(列名1, 列名2, 列名3, ...)] values (值1, 值2, 值3, ...);</span><br></pre></td></tr></table></figure>

<p>其中 [] 内的内容是可选的, 例如, 要给 test 数据库中的 students 表插入一条记录, 执行语句:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">insert into students values(NULL, &quot;王刚&quot;, &quot;男&quot;, 20, &quot;13811371377&quot;);</span><br></pre></td></tr></table></figure>

<p>有时我们只需要插入部分数据, 或者不按照列的顺序进行插入, 可以使用这样的形式进行插入:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">insert into students (name, sex, age) values(&quot;孙丽华&quot;, &quot;女&quot;, 21);</span><br></pre></td></tr></table></figure>

<h2 id="查询表中的数据"><a href="#查询表中的数据" class="headerlink" title="查询表中的数据"></a>查询表中的数据</h2><p>select 语句常用来根据一定的查询规则到数据库中获取数据, 其基本的用法为:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">select 列名称 from 表名称 [查询条件];</span><br></pre></td></tr></table></figure>

<p>例如要查询 students 表中所有学生的名字和年龄, 执行语句</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">select name, age from students;</span><br></pre></td></tr></table></figure>

<p>也可以使用通配符 * 查询表中所有的内容, 语句:<code>select * from students;</code>。</p>
<h3 id="按特定条件查询"><a href="#按特定条件查询" class="headerlink" title="按特定条件查询:"></a>按特定条件查询:</h3><ul>
<li>where 关键词用于指定查询条件, 用法形式为: <code>select 列名称 from 表名称 where 条件;</code></li>
<li>以查询所有性别为女的信息为例, 输入查询语句: <code>select * from students where sex=&quot;女&quot;;</code></li>
<li>where 子句不仅仅支持 “where 列名 = 值” 这种名等于值的查询形式, 对一般的比较运算的运算符都是支持的, 例如 =、&gt;、&lt;、&gt;=、&lt;、!= 以及一些扩展运算符 is [not] null、in、like 等等。 还可以对查询条件使用 or 和 and 进行组合查询, 以后还会学到更加高级的条件查询方式, 这里不再多做介绍。</li>
</ul>
<p>示例:</p>
<ul>
<li>查询年龄在21岁以上的所有人信息: select * from students where age &gt; 21;</li>
<li>查询名字中带有 “王” 字的所有人信息: select * from students where name like “%王%”;</li>
<li>查询id小于5且年龄大于20的所有人信息: select * from students where id&lt;5 and age&gt;20;</li>
</ul>
<h2 id="更新表中的数据"><a href="#更新表中的数据" class="headerlink" title="更新表中的数据"></a>更新表中的数据</h2><p>update 语句可用来修改表中的数据, 基本的使用形式为:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">update 表名称 set 列名称=新值 where 更新条件;</span><br></pre></td></tr></table></figure>

<p>使用示例:</p>
<ul>
<li>将id为5的手机号改为默认的”-“: <code>update students set tel=default where id=5;</code></li>
<li>将所有人的年龄增加1: <code>update students set age=age+1;</code></li>
<li>将手机号为 13288097888 的姓名改为 “张伟鹏”, 年龄改为 19: <code>update students set name=&quot;张伟鹏&quot;, age=19 where tel=&quot;13288097888&quot;;</code></li>
</ul>
<h2 id="删除表中的数据"><a href="#删除表中的数据" class="headerlink" title="删除表中的数据"></a>删除表中的数据</h2><p>delete 语句用于删除表中的数据, 基本用法为:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">delete from 表名称 where 删除条件;</span><br></pre></td></tr></table></figure>

<p>使用示例:</p>
<ul>
<li>删除id为2的行: <code>delete from students where id=2;</code></li>
<li>删除所有年龄小于21岁的数据: <code>delete from students where age&amp;lt;20;</code></li>
<li>删除表中的所有数据: <code>delete from students;</code></li>
</ul>
<h2 id="创建后表的修改"><a href="#创建后表的修改" class="headerlink" title="创建后表的修改"></a>创建后表的修改</h2><p>alter table 语句用于创建后对表的修改, 基础用法如下:</p>
<h3 id="添加列"><a href="#添加列" class="headerlink" title="添加列"></a>添加列</h3><p>基本形式: <code>alter table 表名 add 列名 列数据类型 [after 插入位置];</code></p>
<p>示例:</p>
<p>在表的最后追加列 address: <code>alter table students add address char(60);</code></p>
<p>在名为 age 的列后插入列 birthday: <code>alter table students add birthday date after age;</code></p>
<h3 id="修改列"><a href="#修改列" class="headerlink" title="修改列"></a>修改列</h3><p>基本形式: <code>alter table 表名 change 列名称 列新名称 新数据类型;</code></p>
<p>示例:</p>
<p>将表 tel 列改名为 telphone: <code>alter table students change tel telphone char(13) default &quot;-&quot;;</code></p>
<p>将 name 列的数据类型改为 char(16): <code>alter table students change name name char(16) not null;</code></p>
<h3 id="删除列"><a href="#删除列" class="headerlink" title="删除列"></a>删除列</h3><p>基本形式: <code>alter table 表名 drop 列名称;</code></p>
<p>示例:</p>
<p>删除 birthday 列: <code>alter table students drop birthday;</code></p>
<h3 id="重命名表"><a href="#重命名表" class="headerlink" title="重命名表"></a>重命名表</h3><p>基本形式: <code>alter table 表名 rename 新表名;</code></p>
<p>示例:</p>
<p>重命名 students 表为 workmates: <code>alter table students rename workmates;</code></p>
<h3 id="删除整张表"><a href="#删除整张表" class="headerlink" title="删除整张表"></a>删除整张表</h3><p>基本形式: <code>drop table 表名;</code></p>
<p>示例: 删除 workmates 表: <code>drop table workmates;</code></p>
<h3 id="删除整个数据库"><a href="#删除整个数据库" class="headerlink" title="删除整个数据库"></a>删除整个数据库</h3><p>基本形式: <code>drop database 数据库名;</code></p>
<p>示例: 删除 test 数据库: <code>drop database test;</code></p>
<h2 id="附录"><a href="#附录" class="headerlink" title="附录"></a>附录</h2><h3 id="修改-root-用户密码"><a href="#修改-root-用户密码" class="headerlink" title="修改 root 用户密码"></a>修改 root 用户密码</h3><p>按照本文的安装方式, root 用户默认是没有密码的, 重设 root 密码的方式也较多。</p>
<p>这里仅介绍一种较常用的方式，使用 mysqladmin 方式:</p>
<p>打开命令提示符界面, 执行命令: <code>mysqladmin -u root -p password 新密码</code></p>
<p>执行后提示输入旧密码完成密码修改, 当旧密码为空时直接按回车键确认即可。</p>

    </div>

    
    
    

      <footer class="post-footer">

        

          <div class="post-nav">
            <div class="post-nav-next post-nav-item">
                <a href="/2016/12/24/javascript/cross-domain-methods/" rel="next" title="跨域方法简介">
                  <i class="fa fa-chevron-left"></i> 跨域方法简介
                </a>
            </div>

            <span class="post-nav-divider"></span>

            <div class="post-nav-prev post-nav-item">
                <a href="/2016/12/24/database/mongodb-command-in-common-use/" rel="prev" title="mongodb 常用操作">
                  mongodb 常用操作 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
      </footer>
    
  </article>
  
  
  

  </div>


          </div>
          
    <div class="comments" id="gitalk-container"></div>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#启动"><span class="nav-number">1.</span> <span class="nav-text">启动</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#登录"><span class="nav-number">2.</span> <span class="nav-text">登录</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#创建数据库"><span class="nav-number">3.</span> <span class="nav-text">创建数据库</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#选择所要操作的数据库"><span class="nav-number">4.</span> <span class="nav-text">选择所要操作的数据库</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#建表"><span class="nav-number">5.</span> <span class="nav-text">建表</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#插入数据insert"><span class="nav-number">6.</span> <span class="nav-text">插入数据insert</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#查询表中的数据"><span class="nav-number">7.</span> <span class="nav-text">查询表中的数据</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#按特定条件查询"><span class="nav-number">7.1.</span> <span class="nav-text">按特定条件查询:</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#更新表中的数据"><span class="nav-number">8.</span> <span class="nav-text">更新表中的数据</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#删除表中的数据"><span class="nav-number">9.</span> <span class="nav-text">删除表中的数据</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#创建后表的修改"><span class="nav-number">10.</span> <span class="nav-text">创建后表的修改</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#添加列"><span class="nav-number">10.1.</span> <span class="nav-text">添加列</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#修改列"><span class="nav-number">10.2.</span> <span class="nav-text">修改列</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#删除列"><span class="nav-number">10.3.</span> <span class="nav-text">删除列</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#重命名表"><span class="nav-number">10.4.</span> <span class="nav-text">重命名表</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#删除整张表"><span class="nav-number">10.5.</span> <span class="nav-text">删除整张表</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#删除整个数据库"><span class="nav-number">10.6.</span> <span class="nav-text">删除整个数据库</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#附录"><span class="nav-number">11.</span> <span class="nav-text">附录</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#修改-root-用户密码"><span class="nav-number">11.1.</span> <span class="nav-text">修改 root 用户密码</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <img class="site-author-image" itemprop="image" alt="everlose"
    src="/images/avatar.jpeg">
  <p class="site-author-name" itemprop="name">everlose</p>
  <div class="site-description" itemprop="description">focus on Js、CSS、Node...etc</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">97</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
        <span class="site-state-item-count">17</span>
        <span class="site-state-item-name">分类</span>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">12</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="feed-link motion-element">
    <a href="/atom.xml" rel="alternate">
      <i class="fa fa-rss"></i>RSS
    </a>
  </div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/everlose" title="GitHub &amp;rarr; https:&#x2F;&#x2F;github.com&#x2F;everlose" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="/mailto:ever-lose@foxmail.com" title="E-Mail &amp;rarr; mailto:ever-lose@foxmail.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">everlose</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v4.0.0
  </div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://mist.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Mist</a> v7.5.0
  </div>

        












        
      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>
<script src="/js/utils.js"></script><script src="/js/motion.js"></script>
<script src="/js/schemes/muse.js"></script>
<script src="/js/next-boot.js"></script>



  




  <script src="/js/local-search.js"></script>













  

  

<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css">

<script>
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js', () => {
    var gitalk = new Gitalk({
      clientID: '48fe7d5cb2ac7e2c7fbf',
      clientSecret: '8f67b574218201d3b3ec6efe69276902e711e655',
      repo: 'everlose-blog',
      owner: 'everlose',
      admin: [''],
      id: '824e4421079f9bf02aef7d49ed6ceb77',
        language: 'zh-CN',
      distractionFreeMode: 'true'
    });
    gitalk.render('gitalk-container');
  }, window.Gitalk);
</script>

</body>
</html>
